<!-- 供应商联系人 -->
<template>
  <div>
    <el-table
      ref="customerTable"
      :data="tableData"
      stripe
      style="width: 100%"
      @row-dblclick="getSelectVal"
    >
      <el-table-column
        type="selection"
        width="55"
        align="center"
      ></el-table-column>
      <el-table-column
        type="index"
        width="55"
        align="center"
        label="序号"
      ></el-table-column>

      <el-table-column prop="name" label="姓名">
        <template slot-scope="scope">
          {{ scope.row.name || "--" }}
        </template>
      </el-table-column>
      <el-table-column prop="position" label="职务">
        <template slot-scope="scope">
          {{ scope.row.position || "--" }}
        </template>
      </el-table-column>
      <el-table-column prop="belongCompany" label="所属公司">
        <template slot-scope="scope">
          {{ scope.row.belongCompany || "--" }}
        </template>
      </el-table-column>
      <el-table-column prop="mobile" label="手机号码">
        <template slot-scope="scope">
          {{ scope.row.mobile || "--" }}
        </template>
      </el-table-column>
      <el-table-column prop="sex" label="性别">
        <template slot-scope="scope">
          <span v-if="scope.row.sex == '0'">男</span>
          <span v-else-if="scope.row.sex == '1'">女</span>
          <span v-else>未知</span>
        </template>
      </el-table-column>
      <el-table-column prop="isDefault" label="是否默认联系人">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.isDefault" type="success">是</el-tag>
          <el-tag v-else type="danger">否</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination mt10"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="size"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      background
    >
    </el-pagination>
  </div>
</template>

<script>
import { getSupplierContact } from "@/api/base/data";
export default {
  props: {
    deptLevel: {
      default: "1",
    },
  },
  data() {
    return {
      tableData: [],
      page: 1, //当前页
      limit: 10, //每页条数
      total: 0,
    };
  },
  methods: {
    //分页器size
    handleSizeChange(val) {
      this.limit = val;
      this.getDataList();
    },
    //分页器当前页
    handleCurrentChange(val) {
      this.page = val;
      this.getDataList();
    },
    getSelectVal(val) {
      this.$emit("row-dblclick", val);
    },
    getDataList() {
      let params = {
        limit: this.limit,
        page: this.page,
      };
      getSupplierContact(params).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
      });
    },
  },
  mounted() {
    this.getDataList();
  },
};
</script>

<style></style>
